package com.loveprogrammer.eternity.skill.support.states;

import com.loveprogrammer.eternity.model.Character;
import com.loveprogrammer.eternity.model.console.ConsolePrint;

import java.util.List;

/**
 * @version 1.0.0
 * @description: 生命诅咒
 * @author: eric
 * @date: 2023-01-17 10:04
 **/
public class LifeCurseState extends AbstractNegativeState{

    private Double ratio;

    public LifeCurseState(Character character, List<? extends Character> camp,Double ratio ) {
        super(character,camp);
        this.ratio = ratio;
    }

    @Override
    public int id() {
        return 23;
    }

    @Override
    public String name() {
        return "生命诅咒";
    }

    @Override
    public String desc() {
        return "诅咒，持续掉血";
    }

    @Override
    public void doReset() {

    }

    @Override
    public int counterId() {
        return 89;
    }

    @Override
    public void run() {
        // 如果已经死了就算了
        if(this.getCharacter().checkDead()){
            return;
        }
        // 无视护甲 每次减少最高血量的7%
        int reduceReal = (int) (getCharacter().getHpMax() * 0.07 * ratio);
        getCharacter().hp().addAndGet(-reduceReal);
        ConsolePrint.publishMessage(string + getCharacter().getName() + "(" + getCharacter().getCurrentHp() + "/" +
                getCharacter().getHpMax() + ")" + "收到诅咒失去生命值" + reduceReal);

        if (getCharacter().checkDead()) {
            getNotify().publishDeadEvent(getCharacter(),getCamp());
        }
    }


}
